package leetcode.tree;

import leetcode.array.common.ArrayUtils;
import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

import java.util.List;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution110 {
    public boolean isBalanced(TreeNode root) {
        return TreeUtils.isBalanced(root);
    }
}

public class leetcode110 {
    public static void main(String[] args) {
        Solution110 solution110 = new Solution110();
        Integer[] nums = {3, 9, 20, null, null, 15, 7};
        Integer[] nums1 = {1, 2, 2, 3, 3, null, null, 4, 4};
        Integer[] nums2 = {};
        test110(solution110, nums);
        test110(solution110, nums1);
        test110(solution110, nums2);
    }

    private static void test110(Solution110 solution110, Integer[] nums) {
        List<Integer> list = ArrayUtils.arrayToList(nums);
        TreeNode root = TreeUtils.generateAtreeByBFSList(list);
        System.out.println(TreeUtils.getLeetcodeTreeVals(root));
        System.out.println(solution110.isBalanced(root));
    }
}
